package com.sample.plove.database.service.impl;

import com.sample.plove.database.dao.VipCardRepository;
import com.sample.plove.database.model.VipCardInfoEntity;
import com.sample.plove.database.service.VipCardServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * PackageName:com.sample.plove.database.service.impl
 * Author:Administrator
 * Time:21:17
 * Date:2019/5/18
 * Describe:
 */
@Repository
public class VipCardServerImpl implements VipCardServer {
    private static final Logger log = LoggerFactory.getLogger("VipCardServer");
    @Autowired
    VipCardRepository vipAcardRepository;
    @Override
    public void addVipCardInfo(VipCardInfoEntity info) {
        log.info("");
        vipAcardRepository.save(info);
    }

    @Override
    public Optional<VipCardInfoEntity> findVipCardInfoById(int id) {
        log.info("");
        return vipAcardRepository.findById(id);
    }

    @Override
    public List<VipCardInfoEntity> findAllVipCardInfo() {
        log.info("");
        return vipAcardRepository.findAll();
    }

    @Override
    public void updateVipCardInfo(VipCardInfoEntity entity) {
        log.info("");
        vipAcardRepository.save(entity);
    }

    @Override
    public void removeVipCardInfo(VipCardInfoEntity entity) {
        log.info("");
        vipAcardRepository.delete(entity);
    }

    @Override
    public void cleanVipCardInfo() {
        log.info("");
        vipAcardRepository.deleteAll();
    }
}
